package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	BuyerCategoryEventNew           = "erp.BuyerCategoryNew"
	BuyerCategoryEventBeforeCreate  = "erp.BuyerCategoryBeforeCreate"
	BuyerCategoryEventBeforeUpdate  = "erp.BuyerCategoryBeforeUpdate"
	BuyerCategoryEventBeforeSave    = "erp.BuyerCategoryBeforeCreate erp.BuyerCategoryBeforeUpdate"
	BuyerCategoryEventAfterCreate   = "erp.BuyerCategoryAfterCreate"
	BuyerCategoryEventAfterUpdate   = "erp.BuyerCategoryAfterUpdate"
	BuyerCategoryEventAfterSave     = "erp.BuyerCategoryAfterCreate erp.BuyerCategoryAfterUpdate"
	BuyerCategoryEventDelete        = "erp.BuyerCategoryDelete"
	BuyerCategoryAccessControlEvent = "erp.BuyerCategoryAccessControl"
)

func GetBuyerCategoryConfig() *mgo.DocConfig {
	return BuyerCategory_Config
}

var BuyerCategory_Config *mgo.DocConfig

func init() {
	BuyerCategory_Config = NewBuyerCategoryConfig()
}
func NewBuyerCategoryConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.BuyerCategory",
		Fields: []string{
			"name", "sort", "l", "r", "level", "link", "parent", "children",
		},
		RelationFields: []string{
			"parent", "children",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"parent": {
				Config:     GetBuyerCategoryConfig,
				DocName:    "BuyerCategory",
				JoinType:   "O",
				KeyInside:  "parentId",
				KeyOutSide: "id",
			},
			"children": {
				Config:     GetBuyerCategoryConfig,
				DocName:    "BuyerCategory",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "parentId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
